package com.example.ucs_alg_node_manager.controller;

import com.example.ucs_alg_node_manager.domain.Assemble;
import com.example.ucs_alg_node_manager.service.AssembleService;
import com.example.ucs_alg_node_manager.vo.ReturnVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sources")
@CrossOrigin
@Api("节点数据源管理")
public class SourceController {

    @Resource
    private AssembleService assembleService;

    @ApiOperation("查询源数据")
    @GetMapping("/query")
    public ReturnVO querySources(@RequestParam("type")String type, @RequestParam("id")Integer id){
        return assembleService.getSources(type, id);
    }

    @ApiOperation("编辑源数据（添加 or 修改）")
    @PostMapping("/edit")
    public ReturnVO createSource(@RequestBody Assemble assemble){
        return assembleService.editSource(assemble);
    }

    @ApiOperation("删除源数据")
    @GetMapping("/remove")
    public ReturnVO removeSource(@RequestParam("id") Integer id){
        return assembleService.deleteSource(id);
    }
}
